package com.yudean.esb.service.impl.erp;

import com.yudean.esb.service.ErpClientService;
import com.yudean.esb.service.ErpIdsInvTransactionIntPutService;
import com.yudean.esb.service.handler.ReceiveErpIdsInvTransactionIntService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.jws.WebService;

@WebService(endpointInterface = "com.yudean.esb.service.ErpIdsInvTransactionIntPutService", serviceName = "ErpIdsInvTransactionIntPutServiceService",targetNamespace = "http://service.esb.yudean.com/")
@Service
@Scope("prototype")
public class ErpIdsInvTransactionIntPutServiceImpl implements ErpIdsInvTransactionIntPutService {
    private final static Logger log = LoggerFactory.getLogger(ErpIdsInvTransactionIntPutServiceImpl.class);
    @Resource
    private ReceiveErpIdsInvTransactionIntService receiveErpIdsInvTransactionIntService;

    @Resource
    private ErpClientService erpClientService;
    /**
     * @param serviceID     服务ID
     * @param token         安全验证码
     * @param transactionID 事务ID
     * @param pkg           当前包数
     * @param totalPackage  总共报数
     * @param rollback      是否回滚
     * @param forceReplace  包重复时强制替换
     * @param data          数据内容
     * @return              处理第三方系统推送库存数据到ERP数据库的数据内容
     */
    @Override
    public String putErpIdsInvTransactionIntData(String serviceID, String token, String transactionID, String pkg, String totalPackage, String rollback, String forceReplace, String data) {

        try {
            erpClientService.addErpClientLog(token);
        } catch (Exception e) {
            log.error("save ERP log of /services/erpIdsInvTransactionIntput error:{}", e);
        }

        return receiveErpIdsInvTransactionIntService.putErpIdsInvTransactionIntData(serviceID, token, transactionID, pkg, totalPackage, rollback, forceReplace, data);
    }
}
